# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-react
_pkgname=react
pkgver=1.2.1
pkgrel=1
pkgdesc="OCaml framework for Functional Reactive Programming (FRP)"
url="http://erratique.ch/software/react"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime"
makedepends="ncurses ocaml ocaml-compiler-libs ocaml-findlib ocaml-topkg ocamlbuild opam"
options="textrels"  # needed for ppc64le
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/dbuenzli/$_pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cd "$builddir"

	ocaml pkg/pkg.ml build --tests true
}

check() {
	cd "$builddir"

	ocaml pkg/pkg.ml test
}

package() {
	cd "$builddir"

	opam-installer -i \
		--prefix="$pkgdir/usr" \
		--libdir="$pkgdir/$(ocamlc -where)" \
		$_pkgname.install

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc

	# Remove annotation files and sources.
	cd "$pkgdir"/usr/lib/ocaml/$_pkgname
	rm -f *.cmt* *.ml
}

dev() {
	default_dev
	depends="$pkgname=$pkgver-r$pkgrel"
	local sitelib="usr/lib/ocaml/$_pkgname"

	cd "$pkgdir"/$sitelib

	mkdir -p "$subpkgdir"/$sitelib
	mv *.cmx *.cmxa *.mli "$subpkgdir"/$sitelib/
}

sha512sums="e760c4504519744b66655be113676cb6e3f016fc8a5c59dca063365223d5d5efc66be3ff2b7a2ad3a745975d1b0aaf37634af699d1a706d3bf3b37c1671e81e3  ocaml-react-1.2.1.tar.gz"
